package com.crawler.waf.security.authentication;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
/**
 * 获得安全方面抛出的异常，将异常信息通过内部转发到exception控制器，由异常控制器统一进行处理 *
 */
public class WafAuthenticationExceptionResolver implements AuthenticationEntryPoint {

	@Override
	public void commence(HttpServletRequest request,
			HttpServletResponse response, AuthenticationException authException)
			throws IOException, ServletException {
		//request.setAttribute("lastRequestPath", request.getServletPath());
		request.setAttribute("exception", authException);
		request.getRequestDispatcher("/exception").forward(request, response);

	}

}
